const fs = require("fs");
const path = require("path");

var pathFrom = path.join(__dirname,"1.txt");
var pathTo = path.join(__dirname,"5.txt");

var readStream = fs.createReadStream(pathFrom);
var writeStream = fs.createWriteStream(pathTo);

readStream.pipe(writeStream);
//赋予文件操作权限
writeStream.on("close",()=>{
    var fileObj = fs.statSync(pathFrom);
    fs.chmodSync(pathTo,fileObj.mode);
})